ƒ\[ƒXƒvƒƒOƒ‰ƒ€iBaseballInf.javaj‚Ζ‚R‚Β‚Μƒtƒ@ƒCƒ‹(data.rdf,schema.owl,myrule.rule)



(BaseballInf.java)

package baseball;

 

import java.io.PrintWriter;

import java.util.Iterator;

 

import com.hp.hpl.jena.ontology.OntModel;

import com.hp.hpl.jena.ontology.OntModelSpec;

import com.hp.hpl.jena.rdf.model.InfModel;

import com.hp.hpl.jena.rdf.model.Model;

import com.hp.hpl.jena.rdf.model.ModelFactory;

import com.hp.hpl.jena.rdf.model.Statement;

//import com.hp.hpl.jena.reasoner.Derivation;

import com.hp.hpl.jena.reasoner.Reasoner;

import com.hp.hpl.jena.reasoner.ReasonerRegistry;

import com.hp.hpl.jena.reasoner.rulesys.GenericRuleReasoner;

import com.hp.hpl.jena.reasoner.rulesys.Rule;

import com.hp.hpl.jena.util.FileManager;

 

public class BaseballInf

{

 

    public static void main(String[] args)

    {

           // String ns = "http://www.baseball.com.tw/baseball#";

          

        OntModel schema = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_TRANS_INF);

        schema.read("file:./bin/baseball/schema.owl");

 

        Model data = FileManager.get().loadModel("file:./bin/baseball/data.rdf");

 

        Reasoner owlReasoner = ReasonerRegistry.getOWLReasoner();

        InfModel owlInfModel = ModelFactory.createInfModel(owlReasoner, schema, data);

 

        GenericRuleReasoner reasoner = new GenericRuleReasoner(Rule.rulesFromURL("file:./bin/baseball/myrule.rule"));

        reasoner.setDerivationLogging(true);

        InfModel infModel = ModelFactory.createInfModel(reasoner, owlInfModel);

 

        // Test 1 : Print all data about player "John"

        System.out.println("Test 1 : Print all data about player \"John\"");

        printModelWithSubjectPredicate("John", null, infModel);

        System.out.println("\n");

       

        // Test 2 : Find all players who has hit(s) in Game001

        System.out.println("Test 2 : Find all players who has hit(s) in Game001");

        printModelWithSubjectPredicate("Game001", "HitCreatedBy", infModel);

        System.out.println("\n");

       

        // Test 3 : Show all pitcher/batter Versus pairs

        System.out.println("Test 3 : Show all pitcher/batter Versus pairs");

        printModelWithSubjectPredicate(null, "VersusBatter", infModel);

        System.out.println("\n");

       

       

    }

 

    public static void printModelWithSubjectPredicate(String name1, String name2, InfModel model)

    {

            

        StringBuffer sb = new StringBuffer();

        PrintWriter out = new PrintWriter(System.out);

        for (Iterator itr = model.listStatements(); itr.hasNext();)

        {

            Statement stmt = (Statement) itr.next();

            if ((name1==null || name1.equals(stmt.getSubject().getLocalName()))

                          && (name2==null || name2.equals(stmt.getPredicate().getLocalName())))

                           {

                sb.append("( ");

                sb.append(stmt.getSubject().getLocalName());

                sb.append(", ");

                sb.append(stmt.getPredicate().getLocalName());

                sb.append(", ");

                sb.append(stmt.getObject());

                sb.append(" )");

                System.out.println(sb.toString());

                sb = null;

                sb = new StringBuffer();

 

                //for (Iterator it = model.getDerivation(stmt); it.hasNext();)

                //{

                //   Derivation der = (Derivation) it.next();

                //   der.printTrace(out, true);

                //}

                out.flush();

            }

 

            // out.flush();

        }

    }

 

}

 

{{{{{{

(data.rdf)

<!DOCTYPE rdf:RDF [

    <!ENTITY xsd  "http://www.w3.org/2001/XMLSchema#" >

    <!ENTITY h "http://www.baseball.com.tw/baseball#" > ]>

 

<rdf:RDF

    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"

    xmlns:h="http://www.baseball.com.tw/baseball#">

   

    <!-- Define the game -->

    <rdf:Description rdf:about="&h;Game001">

        <rdf:type rdf:resource="&h;BaseballGame"/>

        <h:GameDate rdf:datatype="&xsd;date">2007-06-25</h:GameDate>

        <h:GameNumber rdf:datatype="&xsd;positiveInteger">1</h:GameNumber> 

    </rdf:Description>

             

    <rdf:Description rdf:about="&h;Inn1_Game001">

        <rdf:type rdf:resource="&h;Inning"/>

        <h:HappenIn rdf:resource="&h;Game001"/>

    </rdf:Description>

    <rdf:Description rdf:about="&h;Inn2_Game001">

        <rdf:type rdf:resource="&h;Inning"/>

        <h:HappenIn rdf:resource="&h;Game001"/>

    </rdf:Description>

    <rdf:Description rdf:about="&h;Inn3_Game001">

        <rdf:type rdf:resource="&h;Inning"/>

        <h:HappenIn rdf:resource="&h;Game001"/>

    </rdf:Description>

   

    <rdf:Description rdf:about="&h;Top1_Game001">

        <rdf:type rdf:resource="&h;TopInning"/>

        <h:HappenIn rdf:resource="&h;Inn1_Game001"/>

    </rdf:Description>

    <rdf:Description rdf:about="&h;Bottom1_Game001">

        <rdf:type rdf:resource="&h;BottomInning"/>

        <h:HappenIn rdf:resource="&h;Inn1_Game001"/>

    </rdf:Description>

    <rdf:Description rdf:about="&h;Top2_Game001">

        <rdf:type rdf:resource="&h;TopInning"/>

        <h:HappenIn rdf:resource="&h;Inn2_Game001"/>

    </rdf:Description>

    <rdf:Description rdf:about="&h;Bottom2_Game001">

        <rdf:type rdf:resource="&h;BottomInning"/>

        <h:HappenIn rdf:resource="&h;Inn2_Game001"/>

    </rdf:Description>

    <rdf:Description rdf:about="&h;Top3_Game001">

        <rdf:type rdf:resource="&h;TopInning"/>

        <h:HappenIn rdf:resource="&h;Inn3_Game001"/>

    </rdf:Description>

    <rdf:Description rdf:about="&h;Bottom3_Game001">

        <rdf:type rdf:resource="&h;BottomInning"/>

        <h:HappenIn rdf:resource="&h;Inn3_Game001"/>

    </rdf:Description>

             

    <!-- Define the teams -->

             

    <rdf:Description rdf:about="&h;Lions">

        <rdf:type rdf:resource="&h;Team"/>

        <h:BeVisitingTeamIn rdf:resource="&h;Game001"/>

    </rdf:Description>

    <rdf:Description rdf:about="&h;Tigers">

        <rdf:type rdf:resource="&h;Team"/>

        <h:BeHomeTeamIn rdf:resource="&h;Game001"/>

    </rdf:Description>

             

    <!-- Define the players -->

             

    <rdf:Description rdf:about="&h;Smith">

        <rdf:type rdf:resource="&h;Player"/>

        <h:BeMemberOf rdf:resource="&h;Lions"/>

        <h:Number rdf:datatype="&xsd;positiveInteger">45</h:Number>

    </rdf:Description>

             

    <rdf:Description rdf:about="&h;Bill">

        <rdf:type rdf:resource="&h;Player"/>

        <h:BeMemberOf rdf:resource="&h;Lions"/>

        <h:Number rdf:datatype="&xsd;positiveInteger">27</h:Number>

    </rdf:Description>

 

    <rdf:Description rdf:about="&h;John">

        <rdf:type rdf:resource="&h;Player"/>

        <h:BeMemberOf rdf:resource="&h;Lions"/>

        <h:Number rdf:datatype="&xsd;positiveInteger">33</h:Number>

        <h:PitchesDuring rdf:resource="&h;Game001"/>

    </rdf:Description>

             

    <rdf:Description rdf:about="&h;David">

        <rdf:type rdf:resource="&h;Player"/>

        <h:BeMemberOf rdf:resource="&h;Lions"/>

        <h:Number rdf:datatype="&xsd;positiveInteger">23</h:Number>

    </rdf:Description>

             

    <rdf:Description rdf:about="&h;Richard">

        <rdf:type rdf:resource="&h;Player"/>

        <h:BeMemberOf rdf:resource="&h;Lions"/>

        <h:Number rdf:datatype="&xsd;positiveInteger">9</h:Number>

    </rdf:Description>

             

    <rdf:Description rdf:about="&h;Tom">

        <rdf:type rdf:resource="&h;Player"/>

        <h:BeMemberOf rdf:resource="&h;Tigers"/>

        <h:Number rdf:datatype="&xsd;positiveInteger">17</h:Number>

        <h:PitchesDuring rdf:resource="&h;Top1_Game001"/>

        <h:PitchesDuring rdf:resource="&h;Top2_Game001"/>

    </rdf:Description>

             

    <rdf:Description rdf:about="&h;Mark">

        <rdf:type rdf:resource="&h;Player"/>

        <h:BeMemberOf rdf:resource="&h;Tigers"/>

        <h:Number rdf:datatype="&xsd;positiveInteger">64</h:Number>

        <h:PitchesDuring rdf:resource="&h;Top3_Game001"/>

    </rdf:Description>

 

    <!-- Define the battings --> 

             

    <rdf:Description rdf:about="&h;Batting0001">

                            <rdf:type rdf:resource="&h;Double"/>

                            <h:HappenIn rdf:resource="&h;Top1_Game001"/>

                            <h:BattedBy rdf:resource="&h;Smith"/>

                            <h:Outs rdf:datatype="&xsd;nonNegativeInteger">0</h:Outs>

                            <h:RBI rdf:datatype="&xsd;nonNegativeInteger">0</h:RBI>

                            <h:Runs rdf:datatype="&xsd;nonNegativeInteger">0</h:Runs>

    </rdf:Description>

             

    <rdf:Description rdf:about="&h;Batting0002">

                            <rdf:type rdf:resource="&h;GroundOut"/>

                            <h:HappenIn rdf:resource="&h;Top1_Game001"/>

                            <h:BattedBy rdf:resource="&h;Bill"/>

                            <h:Has2BRunner rdf:resource="&h;Smith"/>

                            <h:Outs rdf:datatype="&xsd;nonNegativeInteger">0</h:Outs>

                            <h:RBI rdf:datatype="&xsd;nonNegativeInteger">0</h:RBI>

                            <h:Runs rdf:datatype="&xsd;nonNegativeInteger">0</h:Runs>

    </rdf:Description>

 

    <rdf:Description rdf:about="&h;Batting0003">

                            <rdf:type rdf:resource="&h;Homerun"/>

                            <h:HappenIn rdf:resource="&h;Top1_Game001"/>

                            <h:BattedBy rdf:resource="&h;John"/>

                            <h:Has2BRunner rdf:resource="&h;Smith"/>

                            <h:Outs rdf:datatype="&xsd;nonNegativeInteger">1</h:Outs>

                            <h:RBI rdf:datatype="&xsd;nonNegativeInteger">2</h:RBI>

                            <h:Runs rdf:datatype="&xsd;nonNegativeInteger">2</h:Runs>

    </rdf:Description>

             

    <rdf:Description rdf:about="&h;Batting0004">

                            <rdf:type rdf:resource="&h;AirOut"/>

                            <h:HappenIn rdf:resource="&h;Top1_Game001"/>

                            <h:BattedBy rdf:resource="&h;David"/>

                            <h:Outs rdf:datatype="&xsd;nonNegativeInteger">1</h:Outs>

                            <h:RBI rdf:datatype="&xsd;nonNegativeInteger">0</h:RBI>

                            <h:Runs rdf:datatype="&xsd;nonNegativeInteger">0</h:Runs>

    </rdf:Description>

             

    <rdf:Description rdf:about="&h;Batting0005">

                            <rdf:type rdf:resource="&h;StrikeOut"/>

                            <h:HappenIn rdf:resource="&h;Top1_Game001"/>

                            <h:BattedBy rdf:resource="&h;Richard"/>

                            <h:Outs rdf:datatype="&xsd;nonNegativeInteger">2</h:Outs>

                            <h:RBI rdf:datatype="&xsd;nonNegativeInteger">0</h:RBI>

                            <h:Runs rdf:datatype="&xsd;nonNegativeInteger">0</h:Runs>

    </rdf:Description>

             

    <rdf:Description rdf:about="&h;Batting0006">

                            <rdf:type rdf:resource="&h;Single"/>

                            <h:HappenIn rdf:resource="&h;Top2_Game001"/>

                            <h:BattedBy rdf:resource="&h;Smith"/>

                            <h:Outs rdf:datatype="&xsd;nonNegativeInteger">0</h:Outs>

                            <h:RBI rdf:datatype="&xsd;nonNegativeInteger">0</h:RBI>

                            <h:Runs rdf:datatype="&xsd;nonNegativeInteger">0</h:Runs>

    </rdf:Description>

             

    <rdf:Description rdf:about="&h;Batting0007">

                            <rdf:type rdf:resource="&h;SacrificeHit"/>

                            <h:HappenIn rdf:resource="&h;Top2_Game001"/>

                            <h:BattedBy rdf:resource="&h;Bill"/>

                            <h:Has1BRunner rdf:resource="&h;Smith"/>

                            <h:Outs rdf:datatype="&xsd;nonNegativeInteger">0</h:Outs>

                            <h:RBI rdf:datatype="&xsd;nonNegativeInteger">0</h:RBI>

                            <h:Runs rdf:datatype="&xsd;nonNegativeInteger">0</h:Runs>

    </rdf:Description>

 

    <rdf:Description rdf:about="&h;Batting0008">

                            <rdf:type rdf:resource="&h;StrikeOut"/>

                            <h:HappenIn rdf:resource="&h;Top2_Game001"/>

                            <h:BattedBy rdf:resource="&h;John"/>

                            <h:Has2BRunner rdf:resource="&h;Smith"/>

                            <h:Outs rdf:datatype="&xsd;nonNegativeInteger">1</h:Outs>

                            <h:RBI rdf:datatype="&xsd;nonNegativeInteger">0</h:RBI>

                            <h:Runs rdf:datatype="&xsd;nonNegativeInteger">0</h:Runs>

    </rdf:Description>

             

    <rdf:Description rdf:about="&h;Batting0009">

                            <rdf:type rdf:resource="&h;StrikeOut"/>

                            <h:HappenIn rdf:resource="&h;Top2_Game001"/>

                            <h:BattedBy rdf:resource="&h;David"/>

                            <h:Has2BRunner rdf:resource="&h;Smith"/>

                            <h:Outs rdf:datatype="&xsd;nonNegativeInteger">2</h:Outs>

                            <h:RBI rdf:datatype="&xsd;nonNegativeInteger">0</h:RBI>

                            <h:Runs rdf:datatype="&xsd;nonNegativeInteger">0</h:Runs>

    </rdf:Description>

             

    <rdf:Description rdf:about="&h;Batting0010">

                            <rdf:type rdf:resource="&h;BaseOnBalls"/>

                            <h:HappenIn rdf:resource="&h;Top3_Game001"/>

                            <h:BattedBy rdf:resource="&h;Richard"/>

                            <h:Outs rdf:datatype="&xsd;nonNegativeInteger">0</h:Outs>

                            <h:RBI rdf:datatype="&xsd;nonNegativeInteger">0</h:RBI>

                            <h:Runs rdf:datatype="&xsd;nonNegativeInteger">0</h:Runs>

    </rdf:Description>

             

    <rdf:Description rdf:about="&h;Batting0011">

                            <rdf:type rdf:resource="&h;InfieldFly"/>

                            <h:HappenIn rdf:resource="&h;Top3_Game001"/>

                            <h:BattedBy rdf:resource="&h;Smith"/>

                            <h:Has1BRunner rdf:resource="&h;Richard"/>

                            <h:Outs rdf:datatype="&xsd;nonNegativeInteger">0</h:Outs>

                            <h:RBI rdf:datatype="&xsd;nonNegativeInteger">0</h:RBI>

                            <h:Runs rdf:datatype="&xsd;nonNegativeInteger">0</h:Runs>

    </rdf:Description>

             

    <rdf:Description rdf:about="&h;Batting0012">

                            <rdf:type rdf:resource="&h;AirOut"/>

                            <h:HappenIn rdf:resource="&h;Top3_Game001"/>

                            <h:BattedBy rdf:resource="&h;Bill"/>

                            <h:Has1BRunner rdf:resource="&h;Richard"/>

                            <h:Outs rdf:datatype="&xsd;nonNegativeInteger">1</h:Outs>

                            <h:RBI rdf:datatype="&xsd;nonNegativeInteger">0</h:RBI>

                            <h:Runs rdf:datatype="&xsd;nonNegativeInteger">0</h:Runs>

    </rdf:Description>

 

    <rdf:Description rdf:about="&h;Batting0013">

                            <rdf:type rdf:resource="&h;StrikeOut"/>

                            <h:HappenIn rdf:resource="&h;Top3_Game001"/>

                            <h:BattedBy rdf:resource="&h;John"/>

                            <h:Has1BRunner rdf:resource="&h;Richard"/>

                            <h:Outs rdf:datatype="&xsd;nonNegativeInteger">2</h:Outs>

                            <h:RBI rdf:datatype="&xsd;nonNegativeInteger">0</h:RBI>

                            <h:Runs rdf:datatype="&xsd;nonNegativeInteger">0</h:Runs>

    </rdf:Description>

 

</rdf:RDF>

{{{{{{

ischema.owlj

<!DOCTYPE rdf:RDF [

    <!ENTITY xsd  "http://www.w3.org/2001/XMLSchema#" >

    <!ENTITY owl  "http://www.w3.org/2002/07/owl#" >

    <!ENTITY h "http://www.baseball.com.tw/baseball#" > ]>

   

<rdf:RDF

               xmlns:daml="http://www.daml.org/2001/03/daml+oil#"

               xmlns:owl="http://www.w3.org/2002/07/owl#"

               xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

               xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"

               xmlns:xsd ="http://www.w3.org/2001/XMLSchema#">

 

    <!-- Classes about game structure -->

            

    <owl:Class rdf:about="&h;BaseballGame"/>

            

    <owl:Class rdf:about="&h;Inning"/>

            

    <owl:Class rdf:about="&h;HalfInning"/>

            

    <owl:Class rdf:about="&h;TopInning">

        <rdfs:subClassOf rdf:resource="&h;HalfInning" />   

    </owl:Class>

            

    <owl:Class rdf:about="&h;BottomInning">

        <rdfs:subClassOf rdf:resource="&h;HalfInning" />   

    </owl:Class>

            

    <owl:Class rdf:about="&h;Batting"/>

 

    <!-- Classes about game members -->

   

    <owl:Class rdf:about="&h;Team"/>

            

    <owl:Class rdf:about="&h;Player"/>              

 

    <!-- Classes about game event (the batting result) -->

   

    <owl:Class rdf:about="&h;Hit">

        <rdfs:subClassOf rdf:resource="&h;Batting" />   

    </owl:Class>

    <owl:Class rdf:about="&h;Fail">

        <rdfs:subClassOf rdf:resource="&h;Batting" />   

    </owl:Class>

    <owl:Class rdf:about="&h;Walk">

        <rdfs:subClassOf rdf:resource="&h;Batting" />

    </owl:Class>

    <owl:Class rdf:about="&h;Sacrifice">

        <rdfs:subClassOf rdf:resource="&h;Batting" />

    </owl:Class>

   

    <owl:Class rdf:about="&h;Single">

        <rdfs:subClassOf rdf:resource="&h;Hit" />

    </owl:Class>

    <owl:Class rdf:about="&h;Double">

        <rdfs:subClassOf rdf:resource="&h;Hit" />

    </owl:Class>

    <owl:Class rdf:about="&h;Triple">

        <rdfs:subClassOf rdf:resource="&h;Hit" />

    </owl:Class>

    <owl:Class rdf:about="&h;Homerun">

        <rdfs:subClassOf rdf:resource="&h;Hit" />

    </owl:Class>

   

    <owl:Class rdf:about="&h;StrikeOut">

        <rdfs:subClassOf rdf:resource="&h;Fail" />

    </owl:Class>

    <owl:Class rdf:about="&h;GroundOut">

        <rdfs:subClassOf rdf:resource="&h;Fail" />

    </owl:Class>

    <owl:Class rdf:about="&h;AirOut">

        <rdfs:subClassOf rdf:resource="&h;Fail" />

    </owl:Class>

    <owl:Class rdf:about="&h;FieldChoice">

        <rdfs:subClassOf rdf:resource="&h;Fail" />

    </owl:Class>

    <owl:Class rdf:about="&h;Error">

        <rdfs:subClassOf rdf:resource="&h;Fail" />

    </owl:Class>

   

    <owl:Class rdf:about="&h;BaseOnBalls">

        <rdfs:subClassOf rdf:resource="&h;Walk" />

    </owl:Class>

    <owl:Class rdf:about="&h;DeadBall">

        <rdfs:subClassOf rdf:resource="&h;Walk" />

    </owl:Class>

   

    <owl:Class rdf:about="&h;SacrificeHit">

        <rdfs:subClassOf rdf:resource="&h;Sacrifice" />

    </owl:Class>

    <owl:Class rdf:about="&h;SacrificeFly">

        <rdfs:subClassOf rdf:resource="&h;Sacrifice" />

    </owl:Class>

   

    <owl:Class rdf:about="&h;InfieldHit">

        <rdfs:subClassOf rdf:resource="&h;Single" />

    </owl:Class>

   

    <owl:Class rdf:about="&h;SoloHomerun">

        <rdfs:subClassOf rdf:resource="&h;Homerun" />

    </owl:Class>

    <owl:Class rdf:about="&h;GrandSlam">

        <rdfs:subClassOf rdf:resource="&h;Homerun" />

    </owl:Class>

   

    <owl:Class rdf:about="&h;StrikeOutPassedBall">

        <rdfs:subClassOf rdf:resource="&h;StrikeOut" />

    </owl:Class>

   

    <owl:Class rdf:about="&h;GroundedIntoDoublePlay">

        <rdfs:subClassOf rdf:resource="&h;GroundOut" />

    </owl:Class>

   

    <owl:Class rdf:about="&h;InfieldFly">

        <rdfs:subClassOf rdf:resource="&h;AirOut" />

    </owl:Class>

 

    <!-- Datatype Properties about game structure -->

 

    <owl:DatatypeProperty rdf:about="&h;GameDate">

        <rdfs:domain rdf:resource="&h;BaseballGame" />   

        <rdfs:range  rdf:resource="&xsd;date"/>

    </owl:DatatypeProperty>

   

    <owl:DatatypeProperty rdf:about="&h;GameNumber">

        <rdfs:domain rdf:resource="&h;BaseballGame" />   

        <rdfs:range  rdf:resource="&xsd;positiveInteger"/>

    </owl:DatatypeProperty>

 

    <!-- Datatype Properties about game members -->  

 

    <owl:DatatypeProperty rdf:about="&h;Number">

        <rdfs:domain rdf:resource="&h;Player" />   

        <rdfs:range  rdf:resource="&xsd;positiveInteger"/>

    </owl:DatatypeProperty>

 

    <!-- Datatype Properties about game events -->

 

    <owl:DatatypeProperty rdf:about="&h;Outs">

        <rdfs:domain rdf:resource="&h;Batting" />   

        <rdfs:range  rdf:resource="&xsd;nonNegativeInteger"/>

    </owl:DatatypeProperty>

             

    <owl:DatatypeProperty rdf:about="&h;RBI">

        <rdfs:domain rdf:resource="&h;Batting" />   

        <rdfs:range  rdf:resource="&xsd;nonNegativeInteger"/>

    </owl:DatatypeProperty>

   

    <owl:DatatypeProperty rdf:about="&h;Runs">

        <rdfs:domain rdf:resource="&h;Batting" />   

        <rdfs:range  rdf:resource="&xsd;nonNegativeInteger"/>

    </owl:DatatypeProperty>

 

    <!-- Object Properties between the classes -->

   

    <owl:ObjectProperty rdf:about="&h;Happens" >

        <rdf:type rdf:resource="&owl;TransitiveProperty" />

    </owl:ObjectProperty>

            

    <owl:ObjectProperty rdf:about="&h;HappenIn">

        <owl:inverseOf rdf:resource="&h;Happens"/>

        <rdf:type rdf:resource="&owl;TransitiveProperty" />

    </owl:ObjectProperty>

  

    <owl:ObjectProperty rdf:about="&h;HasTeam">

        <rdfs:domain rdf:resource="&h;BaseballGame" />

        <rdfs:range rdf:resource="&h;Team" />

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;BeTeamIn">

        <rdfs:domain rdf:resource="&h;Team" />

        <rdfs:range rdf:resource="&h;BaseballGame" />

        <owl:inverseOf rdf:resource="&h;HasTeam"/>

    </owl:ObjectProperty>              

   

    <owl:ObjectProperty rdf:about="&h;HasHomeTeam">

        <rdfs:subPropertyOf rdf:resource="&h;HasTeam" />

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;BeHomeTeamIn">

        <rdfs:subPropertyOf rdf:resource="&h;BeTeamIn" />

        <owl:inverseOf rdf:resource="&h;HasHomeTeam"/>

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;HasVisitingTeam">

        <rdfs:subPropertyOf rdf:resource="&h;HasTeam" />

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;BeVisitingTeamIn">

        <rdfs:subPropertyOf rdf:resource="&h;BeTeamIn" />

        <owl:inverseOf rdf:resource="&h;HasVisitingTeam"/>

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;HasPlayer">

        <rdfs:domain rdf:resource="&h;BaseballGame" />

        <rdfs:range rdf:resource="&h;Player" />

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;BePlayerIn">

        <rdfs:domain rdf:resource="&h;Player" />

        <rdfs:range rdf:resource="&h;BaseballGame" />

        <owl:inverseOf rdf:resource="&h;HasPlayer"/>

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;HasMember">

        <rdfs:domain rdf:resource="&h;Team" />

        <rdfs:range rdf:resource="&h;Player" />

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;BeMemberOf">

        <rdfs:domain rdf:resource="&h;Player" />

        <rdfs:range rdf:resource="&h;Team" />

        <owl:inverseOf rdf:resource="&h;HasMember"/>

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;HasRBI">

        <rdfs:domain rdf:resource="&h;Player" />

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;RBICreatedBy">

        <rdfs:range rdf:resource="&h;Player" />

        <owl:inverseOf rdf:resource="&h;HasRBI"/>

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;HasHit">

        <rdfs:domain rdf:resource="&h;Player" />

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;HitCreatedBy">

        <rdfs:range rdf:resource="&h;Player" />

        <owl:inverseOf rdf:resource="&h;HasHit"/>

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;HasHomerun">

        <rdfs:domain rdf:resource="&h;Player" />

        <rdfs:subPropertyOf rdf:resource="&h;HasHit"/>

    </owl:ObjectProperty>   

   

    <owl:ObjectProperty rdf:about="&h;HomerunCreatedBy">

        <rdfs:range rdf:resource="&h;Player" />

        <owl:inverseOf rdf:resource="&h;HasHomerun"/>

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;RunsAllow">

        <rdfs:domain rdf:resource="&h;Player" />

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;RunsAllowedBy">

        <rdfs:range rdf:resource="&h;Player" />

        <owl:inverseOf rdf:resource="&h;RunsAllow"/>

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;HomerunAllow">

        <rdfs:domain rdf:resource="&h;Player" />

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;HomerunAllowedBy">

        <rdfs:range rdf:resource="&h;Player" />

        <owl:inverseOf rdf:resource="&h;HomerunAllow"/>

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;HomerunOn">

        <rdfs:domain rdf:resource="&h;Player" />

        <rdfs:range rdf:resource="&h;Player" />

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;HomerunBy">

        <rdfs:domain rdf:resource="&h;Player" />

        <rdfs:range rdf:resource="&h;Player" />

        <owl:inverseOf rdf:resource="&h;HomerunOn"/>

    </owl:ObjectProperty>

             

    <owl:ObjectProperty rdf:about="&h;Bats">

        <rdfs:range rdf:resource="&h;Batting" />

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;BattedBy">

        <rdfs:domain rdf:resource="&h;Batting" />

        <owl:inverseOf rdf:resource="&h;Bats"/>

        <rdf:type rdf:resource="&owl;FunctionalProperty"/>

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;Pitches">

        <rdfs:domain rdf:resource="&h;Player" />

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;PitchedBy">

        <rdfs:range rdf:resource="&h;Player" />

        <owl:inverseOf rdf:resource="&h;Pitches"/>

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;PitchesDuring">

                  <rdfs:domain rdf:resource="&h;Player" />

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;PitchedByDuring">

        <rdfs:range rdf:resource="&h;Player" />

        <owl:inverseOf rdf:resource="&h;PitchesDuring"/>

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;VersusTeam">

                  <rdfs:range rdf:resource="&h;Team" />

    </owl:ObjectProperty>

 

    <owl:ObjectProperty rdf:about="&h;VersusPitcher">

                  <rdfs:range rdf:resource="&h;Player" />

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;VersusBatter">

                  <rdfs:range rdf:resource="&h;Player" />

                  <owl:inverseOf rdf:resource="&h;VersusPitcher"/>

    </owl:ObjectProperty>

 

    <owl:ObjectProperty rdf:about="&h;OnScoringPosition">

        <rdfs:domain rdf:resource="&h;Player" />

        <rdfs:range rdf:resource="&h;Batting" />

    </owl:ObjectProperty>

             

    <owl:ObjectProperty rdf:about="&h;OnFirstBase">

        <rdfs:domain rdf:resource="&h;Player" />

        <rdfs:range rdf:resource="&h;Batting" />

    </owl:ObjectProperty>

            

    <owl:ObjectProperty rdf:about="&h;OnSecondBase">

        <rdfs:subPropertyOf rdf:resource="&h;OnScoringPosition" />

    </owl:ObjectProperty>

            

    <owl:ObjectProperty rdf:about="&h;OnThirdBase">

        <rdfs:subPropertyOf rdf:resource="&h;OnScoringPosition" />

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;HasScoringPositionRunner">

        <rdfs:domain rdf:resource="&h;Batting" />

        <rdfs:range rdf:resource="&h;Player" />

        <owl:inverseOf rdf:resource="&h;OnScoringPosition"/>

    </owl:ObjectProperty>

            

    <owl:ObjectProperty rdf:about="&h;Has1BRunner">

        <rdfs:domain rdf:resource="&h;Batting" />

        <rdfs:range rdf:resource="&h;Player" />

        <owl:inverseOf rdf:resource="&h;OnFirstBase"/>

    </owl:ObjectProperty>             

            

    <owl:ObjectProperty rdf:about="&h;Has2BRunner">

        <rdfs:subPropertyOf rdf:resource="&h;HasScoringPositionRunner" />

        <owl:inverseOf rdf:resource="&h;OnSecondBase"/>

    </owl:ObjectProperty>

   

    <owl:ObjectProperty rdf:about="&h;Has3BRunner">

        <rdfs:subPropertyOf rdf:resource="&h;HasScoringPositionRunner" />

        <owl:inverseOf rdf:resource="&h;OnThirdBase"/>

    </owl:ObjectProperty>             

 

</rdf:RDF>

{{{{

imyrule.rulej

@prefix h: <http://www.baseball.com.tw/baseball#> .

@include <RDFS>.

@include <OWL>.

 

[Pitches_Infer: (?pitcher h:Pitches ?event1) (?event1 h:HappenIn ?event2)

              -> (?pitcher h:Pitches ?event2)]

             

[Pitches_Infer2: (?pitcher h:PitchesDuring ?event)

              -> (?pitcher h:Pitches ?event)]

             

[PitchesDuring_Infer:

              (?pitcher h:PitchesDuring ?game) (?game rdf:type h:BaseballGame)

              (?pitcher h:BeMemberOf ?team) (?team h:BeHomeTeamIn ?game)

              (?game h:Happens ?event) (?event rdf:type h:TopInning)

              -> (?pitcher h:PitchesDuring ?event)]

             

[PitchesDuring_Infer2:

              (?pitcher h:PitchesDuring ?game) (?game rdf:type h:BaseballGame)

              (?pitcher h:BeMemberOf ?team) (?team h:BeVisitingTeamIn ?game)

              (?game h:Happens ?event) (?event rdf:type h:BottomInning)

              -> (?pitcher h:PitchesDuring ?event)]

                           

[PitchesDuring_Infer3: (?pitcher h:PitchesDuring ?event1) (?event1 rdf:type h:HalfInning) (?event1 h:Happens ?event2)

              -> (?pitcher h:PitchesDuring ?event2)]

             

[PitchesDuring_Infer4: (?pitcher h:Pitches ?batting) (?batting rdf:type h:Batting)

              -> (?pitcher h:PitchesDuring ?batting)]

 

[HasPlayer_Infer: (?game h:HasTeam ?team) (?team h:HasMember ?player)

              -> (?game h:HasPlayer ?player)]

             

[Versus_Infer: (?pitcher h:Pitches ?batting) (?batting h:BattedBy ?batter)

              -> (?pitcher h:VersusBatter ?batter) (?batter h:VersusPitcher ?pitcher)]

             

[VersusTeam_Infer: (?pitcher h:VersusBatter ?batter) (?pitcher h:BeMemberOf ?team1) (?batter h:BeMemberOf ?team2)

              -> (?team1 h:VersusTeam ?team2) (?pitcher h:VersusTeam ?team2) (?batter h:VersusTeam ?team1)]

             

[HasRBI_Infer: (?batter h:Bats ?batting) (?batting h:RBI ?x) greaterThan(?x, 0)

              -> (?batter h:HasRBI ?batting)]

             

[HasRBI_Infer2: (?batter h:HasRBI ?event1) (?event1 h:HappenIn ?event2)

              -> (?batter h:HasRBI ?event2)]

             

[HasHit_Infer: (?batter h:Bats ?batting) (?batting rdf:type h:Hit)

              -> (?batter h:HasHit ?batting)]

             

[HasHit_Infer2: (?batter h:HasHit ?event1) (?event1 h:HappenIn ?event2)

              -> (?batter h:HasHit ?event2)]

             

[HasHomerun_Infer: (?batter h:Bats ?batting) (?batting rdf:type h:Homerun)

              -> (?batter h:HasHomerun ?batting)]

             

[HasHomerun_Infer2: (?batter h:HasHomerun ?event1) (?event1 h:HappenIn ?event2)

              -> (?batter h:HasHomerun ?event2)]

             

[RunsAllow_Infer: (?pitcher h:Pitches ?batting) (?batting h:Runs ?x) greaterThan(?x, 0)

              -> (?pitcher h:RunsAllow ?batting)]

             

[RunsAllow_Infer2: (?pitcher h:RunsAllow ?event1) (?event1 h:HappenIn ?event2)

              -> (?pitcher h:RunsAllow ?event2)]

             

[HomerunAllow_Infer: (?pitcher h:Pitches ?batting) (?batting rdf:type h:Homerun)

              -> (?pitcher h:HomerunAllow ?batting)]

             

[HomerunAllow_Infer2: (?pitcher h:HomerunAllow ?event1) (?event1 h:HappenIn ?event2)

              -> (?pitcher h:HomerunAllow ?event2)]

             

[HomerunOn_Infer: (?batter h:Bats ?batting) (?batting rdf:type h:Homerun) (?pitcher h:Pitches ?batting)

              -> (?batter h:HomerunOn ?pitcher)]

 

{{{I‚ν‚θ{{{